package main

import "fmt"

func main0801() {
	var slice [] int = [] int{1, 2, 3, 4, 5}
	slice[0] = 123
	slice[2] = 234
	slice = append(slice, 456)
	slice = append(slice, 7, 8, 9)
	fmt.Println(slice)
	for i := 0; i < len(slice); i++ {
		fmt.Println(slice[i])
	}
	for i, v := range slice {
		fmt.Println(i, v)
	}
}

func main() {
	// 在定义切片时可以指定长度 make(切片类型，长度)
	//var slice [] int = make([]int,10)
	//slice = append(slice,1,2,3,4,5,6,7,8,9,10)

	// 通过自动推导类型创建切片
	slice := []int{1, 2, 3}
	fmt.Println(slice)
}
